home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / tcflush.c < prev    next >
C/C++ Source or Header  |  1994-03-01  |  693b  |  44 lines

  1. /*
  2. Public domain termios tcflush() for the MiNT library
  3. 10 October 1993 entropy@terminator.rs.itd.umich.edu -- first attempt
  4. */
  5.  
  6. #include <mintbind.h>
  7. #include <errno.h>
  8. #include <file.h>
  9. #include <ioctl.h>
  10. #include <types.h>
  11. #include <termios.h>
  12.  
  13. int
  14. tcflush(fd, action)
  15.   int fd;
  16.   int action;
  17. {
  18.   long flushtype;
  19.   long r;
  20.  
  21.   switch (action)
  22.   {
  23.     case TCIFLUSH:
  24.       flushtype = FREAD;
  25.       break;
  26.     case TCOFLUSH:
  27.       flushtype = FWRITE;
  28.       break;
  29.     case TCIOFLUSH:
  30.       flushtype = 0;
  31.       break;
  32.     default:
  33.       errno = EINVAL;
  34.       return -1;
  35.   }
  36.   r = Fcntl((short) fd, &flushtype, TIOCFLUSH);
  37.   if (r < 0) {
  38.     errno = (int) -r;
  39.     return -1;
  40.   }
  41.   return 0;
  42. }
  43.  
  44.